home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / RCS / lstFindFrom.c,v < prev    next >
Encoding:
Text File  |  1992-05-19  |  1.9 KB  |  94 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     88.11.17.20.52.37;  author adam;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.6
  21. log
  22. @checked in with -k by kupfer at 92.05.18.17.32.38.
  23. @
  24. text
  25. @/*-
  26.  * LstFindFrom.c --
  27.  *    Find a node on a list from a given starting point. Used by Lst_Find.
  28.  *
  29.  * Copyright (c) 1988 by University of California Regents
  30.  *
  31.  * Permission to use, copy, modify, and distribute this
  32.  * software and its documentation for any purpose and without
  33.  * fee is hereby granted, provided that the above copyright
  34.  * notice appears in all copies.  Neither the University of California nor
  35.  * Adam de Boor makes any representations about the suitability of this
  36.  * software for any purpose.  It is provided "as is" without
  37.  * express or implied warranty.
  38.  */
  39. #ifndef lint
  40. static char *rcsid =
  41. "$Id: lstFindFrom.c,v 1.6 88/11/17 20:52:37 adam Exp $ SPRITE (Berkeley)";
  42. #endif lint
  43.  
  44. #include    "lstInt.h"
  45.  
  46. /*-
  47.  *-----------------------------------------------------------------------
  48.  * Lst_FindFrom --
  49.  *    Search for a node starting and ending with the given one on the
  50.  *    given list using the passed datum and comparison function to
  51.  *    determine when it has been found.
  52.  *
  53.  * Results:
  54.  *    The found node or NILLNODE
  55.  *
  56.  * Side Effects:
  57.  *    None.
  58.  *
  59.  *-----------------------------------------------------------------------
  60.  */
  61. LstNode
  62. Lst_FindFrom (l, ln, d, cProc)
  63.     Lst                  l;
  64.     register LstNode    ln;
  65.     register ClientData d;
  66.     register int    (*cProc)();
  67. {
  68.     register ListNode    tln;
  69.     Boolean        found = FALSE;
  70.     
  71.     if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
  72.     return (NILLNODE);
  73.     }
  74.     
  75.     tln = (ListNode)ln;
  76.     
  77.     do {
  78.     if ((*cProc) (tln->datum, d) == 0) {
  79.         found = TRUE;
  80.         break;
  81.     } else {
  82.         tln = tln->nextPtr;
  83.     }
  84.     } while (tln != (ListNode)ln && tln != NilListNode);
  85.     
  86.     if (found) {
  87.     return ((LstNode)tln);
  88.     } else {
  89.     return (NILLNODE);
  90.     }
  91. }
  92.  
  93. @
  94.